package com.yunxi.order.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * OpenFeign 远程调用请求拦截器
 *
 * @author: lidy
 * @date: 2025-01-18 12:52
 */
@Component
public class FeignClientRequestInterceptor implements RequestInterceptor {

    /**
     * 请求拦截器
     *
     * @param requestTemplate 请求模板
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
        // 往请求头里面放一个 X-Token 的 UUID 值
        requestTemplate.header("X-Token", UUID.randomUUID().toString());
    }

}
